# syntax = docker/dockerfile:1.2

# FROM node:14-alpine
FROM 200-registry.intra.jiasule.com/cloud-monitor/web_base:0.0.2

ARG VERSION=latest
ARG NPM_REGISTRY=10.255.8.129:4873
ARG NPM_TOKEN
ARG DEBUG

ADD config /app
ADD upgradePacakgeJsonVersion.js /app
ADD package.json /tmp/package.json

WORKDIR /app

RUN printf "@knownsec:registry=https://npm.prod.intra.knownsec.com/\nstrict-ssl=false\nregistry=https://$NPM_REGISTRY/\nalways-auth=true\n//$NPM_REGISTRY/:_authToken=\"$NPM_TOKEN\"" > ~/.npmrc
RUN yarn config set strict-ssl false
RUN cat ~/.npmrc
RUN node ./upgradePacakgeJsonVersion.js
RUN cat package.json
RUN yarn install && rm ~/.npmrc

RUN chown -R node:node /app
USER node
RUN DEBUG=$DEBUG NODE_OPTIONS=--max-old-space-size=4096 UV_THREADPOOL_SIZE=128 yarn run bundle
EXPOSE 8000
CMD yarn start
